package com.shupian.controller;

import com.shupian.domain.ResponseResult;
import com.shupian.domain.dto.AddTagDto;
import com.shupian.domain.dto.TagListDto;
import com.shupian.domain.vo.TagVo;
import com.shupian.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Min;


@RestController
@RequestMapping("/content/tag")
public class TagController {
    @Autowired
    private TagService tagService;

    @GetMapping("/list")
    public ResponseResult list(@Min(1) Integer pageNum , @Min(1) Integer pageSize, TagListDto tagListDto){
        return tagService.pageTagList(pageNum,pageSize, tagListDto);
    }
    @PostMapping
    public ResponseResult addTag(@RequestBody @Valid AddTagDto tagDto){
        return tagService.addTag(tagDto);

    }
    @DeleteMapping("/{id}")
    public ResponseResult deleteTag(@PathVariable("id") @Min(1) Long id){
        return tagService.deleteTag(id);
    }
    @GetMapping("/{id}")
    public ResponseResult getTagById(@PathVariable @Min(1) Long id){
        return tagService.getTagById(id);
    }
    @PutMapping
    public ResponseResult updateTag(@RequestBody @Valid TagVo tagVo){
        return tagService.updateTag(tagVo);
    }
    @GetMapping("/listAllTag")
    public ResponseResult getAllTag(){
        return tagService.getAllTag();
    }



}
